package com.jinlingxiu.app.mvp.ui.activity

import android.content.Intent
import android.os.Bundle
import com.jaeger.library.StatusBarUtil
import com.jinlingxiu.app.R
import com.jinlingxiu.app.mvp.contract.WelcomeContract
import com.jinlingxiu.app.mvp.presenter.WelcomePresenter
import com.xdja.easymvp.base.BaseActivity
import kotlinx.android.synthetic.main.activity_welcome.*
import org.koin.androidx.scope.lifecycleScope

/**
 * 描述:
 * Create by yuanwanli
 * Date 2020/09/10
 */
class WelcomeActivity : BaseActivity<WelcomePresenter>(), WelcomeContract.View {
    override var mPresenter: WelcomePresenter? = lifecycleScope.get()
    private var mCountdownNumber = 6
    override fun initView(savedInstanceState: Bundle?): Int = R.layout.activity_welcome


    override fun initData(savedInstanceState: Bundle?) {
        StatusBarUtil.setTransparent(this)
        StatusBarUtil.setLightMode(this)
        mPresenter?.getCountdown()
    }

    override fun showCountdown() {
        mCountdownNumber--
        tvCountdownNumber.text = "${mCountdownNumber}s"
        if (mCountdownNumber <= 0) {
            startActivity(Intent(this, LoginActivity::class.java))
            finish()
        }
    }
}
